<template>
	<view class="news">
		<news-item :list = "newsList" @itemClick = "goDetail"></news-item>
	</view>
</template>

<script>
	import newItem from "../../components/news-item/news-item.vue"
	export default {
		components:{
			"news-item":newItem
		},
		data() {
			return {
				newsList:[]
			}
		},
		onLoad() {
			this.getNews()
		},
		methods: {
			getNews(){
				this.$myRequest({
					url:'getNews.json'
				}).then(res=>{
					console.log(res.data.message)
					this.newsList = res.data.message
				})
			},
			goDetail(id){
				uni.navigateTo({
					url:'/pages/news-detail/news-detail?id='+id,
				})
			}
		}
	}
</script>

<style>

</style>
